<?php

namespace app\api\controller;

use think\Controller;

class Common extends Controller
{
    
    protected $pagesize;
    
    public function initialize()
    {
        //系统信息
        $sys = cache('System');
        $this->assign('sys', $sys);
        
        //获取控制方法
        $action = request()->action();
        $controller = request()->controller();
        $this->assign('action', ($action));
        $this->assign('controller', strtolower($controller));
//        define('MODULE_NAME', strtolower($controller));
//        define('ACTION_NAME', strtolower($action));
        
        $gs_list = \db('goods_cat')->where('pid', 0)->where('status', 1)->order('sort asc')->select();
        foreach ($gs_list as &$v) {
            $v['child'] = \db('goods_cat')->where('pid', $v['id'])->where('status', 1)->order('sort asc')->select();
        }
        $this->assign('gs_list', $gs_list);
        
        //友情链接
        /*$linkList = cache('linkList');
        if (!$linkList) {
            $linkList = Db::name('links')->where('open', 1)->order('sort asc')->select();
            cache('linkList', $linkList, 3600);
        }
        $this->assign('linkList', $linkList);*/
    }
    
    public function _empty()
    {
        return $this->error('空操作，返回上次访问页面中...');
    }
}